package com.lx.oms.controller.service.impl;

import java.math.BigInteger;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lx.oms.common.entity.Page;
import com.lx.oms.common.entity.Query;
import com.lx.oms.common.entity.R;
import com.lx.oms.common.utils.CommonUtils;
import com.lx.oms.controller.entity.AccountEntity;
import com.lx.oms.controller.manager.AccountManager;
import com.lx.oms.controller.service.AccountService;

/**
 * 账户余额
 *
 * @author houzhong
 * @date 2018年10月30日 下午2:02:43
 */
@Service("accountService")
public class AccountServiceImpl implements AccountService {

	@Autowired
	private AccountManager accountManager;

	@Override
	public Page<AccountEntity> listAccount(Map<String, Object> params) {
		Query query = new Query(params);
		Page<AccountEntity> page = new Page<>(query);
		accountManager.listAccount(page, query);
		return page;
	}

	@Override
	public R saveAccount(AccountEntity role) {
		int count = accountManager.saveAccount(role);
		return CommonUtils.msg(count);
	}

	@Override
	public R getAccountById(BigInteger id) {
		AccountEntity tAccount = accountManager.getAccountById(id);
		return CommonUtils.msg(tAccount);
	}

	@Override
	public R updateAccount(AccountEntity tAccount) {
		int count = accountManager.updateAccount(tAccount);
		return CommonUtils.msg(count);
	}

	@Override
	public R batchRemove(String[] id) {
		int count = accountManager.batchRemove(id);
		return CommonUtils.msg(id, count);
	}

	@Override
	public AccountEntity getAccountId(BigInteger id) {
		AccountEntity tAccount = accountManager.getAccountById(id);
		return tAccount;
	}

}
